iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 23
0
自我挑戰組

30 Days on Life and Its Challenges系列 第 23

[DAY-23] 站直、抬起頭 / 善待自己,就像善待任何你有責任幫助的人

  • 分享至 

  • xImage
  •  

站直、抬起頭

善待自己,就像善待任何你有責任幫助的人

  • 跟自己說言行一致,對所有人看所以事物都要用平常心來處理 :)
  • 和韓第爺爺說得一樣,你像樣怎麼被對待就怎麼樣對待別人。

/images/emoticon/emoticon08.gif

碼農小園地

  • 看用的是什麼 browser

    • Navigator
      • The Navigator interface represents the state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities.
function () {
    var ua = navigator.userAgent, tem,
      M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
    if (/trident/i.test(M[1])) {
      tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
      return 'IE ' + (tem[1] || '');
    }
    if (M[1] === 'Chrome') {
      tem = ua.match(/\b(OPR|Edge?)\/(\d+)/);
      if (tem != null) return tem.slice(1).join(' ').replace('OPR', 'Opera').replace('Edg ', 'Edge ');
    }
    M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
    if ((tem = ua.match(/version\/(\d+)/i)) != null) M.splice(1, 1, tem[1]);
    return M.join(' ');
  };
// this code snippet splits a string in a special notation

if (navigator.userAgent.indexOf("Chrome") !== -1){
    // YES! The user is suspected to support look-behind regexps
    // DO NOT USE /(?<=[A-Z])/. It will cause a syntax error in
    //  browsers that do not support look-behind expressions
    //  because all browsers parse the entire script, including
    //  sections of the code that are never executed.
    var camelCaseExpression = new RegExp("(?<=[A-Z])"); 
    var splitUpString = function(str) {
        return (""+str).split(camelCaseExpression);
    };
} else {
    /*This fallback code is much less performant, but works*/
    var splitUpString = function(str){
        return str.replace(/[A-Z]/g,"z$1").split(/z(?=[A-Z])/g);
    };
}
console.log(splitUpString("fooBare")); // ["fooB", "are"]
console.log(splitUpString("jQWhy")); // ["jQ", "W", "hy"]

Reference


上一篇
[DAY-22] 別留下遺憾
下一篇
[DAY-24] 結交希望你變得更好的朋友 / 跟昨天的自己比,而不是跟今天的別人比
系列文
30 Days on Life and Its Challenges30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言